function fb_clone(obj)
	local uptable = {}
	local function _copy(obj)
		if type(obj) ~= "table" then 
			return obj 
		elseif uptable[obj] then
			return uptable[obj]
		end 

		local curtable = {}
		uptable[obj] = curtable
		for k,v in pairs(obj) do
			curtable[_copy(k)] = _copy(v)
		end
		return setmetatable(curtable, getmetatable(obj))
	end
	return _copy(obj)
end

function fb_getSuper(cls, name)
	if not name then return cls.super end
	if not cls or cls:getName() == name then return cls end
	return fb_getSuper(cls.super, name)
end

function fb_class(name, super)
	local cls = nil
	local stype = type(super)
	if stype ~= "function" and stype ~= "table" then
		stype = nil
		super = nil
	end

	if super and (super.__ctype == nil or super.__ctype == 1) then
		cls = {}
		if super.__ctype then
			for k,v in pairs(super) do cls[k] = v end
			cls.__creat = super.__creat
		else
			cls.__creat = function( ... ) return super:creat(...) end
		end
		cls.__cname = name
		cls.__ctype = 1
		cls.__index = cls
		cls.super = super
		function cls.getName() return cls.__cname end
		function cls.getSuper(la, sname) return fb_getSuper(cls, sname) end
		function cls.ctor( ... ) end
		function cls.new( ... )
			local inst = cls.__creat(...)
			inst.__class = cls
			for k,v in pairs(cls) do inst[k] = v end
			if cls.super and cls.super.ctor then cls.super.ctor(inst, ...) end
			inst.ctor(inst, ...)
			return inst
		end
	else
		if super then
			cls = fb_clone(super)
			cls.super = super
		else
			cls = {ctor = function () end}
		end
		cls.__cname = name
		cls.__ctype = 2
		cls.__index = cls

		function cls.getName() return cls.__cname end
		function cls.getSuper(la, sname) return fb_getSuper(cls, sname) end
		function cls.ctor( ... ) end
		function cls.new(la, ... )
			local inst = setmetatable({}, cls)
			inst.__class = cls
			local bases = {}
			local __super = cls.super
			while __super ~= nil do
				table.insert(bases, __super)
				__super = __super.super
			end

			for k=#bases,1, -1 do
				local __super = bases[k]
				if __super.ctor then __super.ctor(inst, ...) end				
			end
			inst:ctor(...)
			return inst
		end
	end
	return cls
end

--- 清除fb_class所有数据
function fb_clear(cls)
	for i, v in pairs(cls) do
		if type(v) ~= "function" then
			cls[i] = nil
		end
	end
end
-- table乱序
function DisorderTable(tt, cnt)
	local num = cnt or #tt
	for i=1,num do
		local index = math.random(1, num)
		local tmp = tt[i]
		tt[i] = tt[index]
		tt[index] = tmp
	end
	return tt
end

function ReverseTable(tt)
	local len = #tt
	local half = math.floor(len * 0.5)
	if len > 0 then
		local tmp = nil
		for i = 1, half do
			tmp = tt[i]
			tt[i] = tt[len - i + 1]
			tt[len - i + 1] = tmp
		end
	end
end
-- 获取table长度
function GetTableLen(_table)
	if type(_table) ~= "table" then return 0 end
	local cnt =  0
	for k, v in pairs(_table) do cnt = cnt + 1 end
	return cnt
end
-- table是否包含值
function HasValue(tab, value)
	if not tab or GetTableLen(tab) == 0 then return false end
	for i, v in pairs(tab) do
		if v == value then
			return true
		end
	end
	return false
end
-- table是否包含键
function HasKey(tab, key)
	if not tab or GetTableLen(tab) == 0 then return false end
	for i, v in pairs(tab) do
		if key == i then
			return true
		end
	end
	return false
end

---_type   1   floor
---        2   0.5
---        3   up
function NumberCutting(num, fig, _type)
	fig = fig or 1
	local dit = 1
	for i = 1, fig do dit = dit * 10 end
	_type = _type or 1

	if _type == 1 then
		return math.floor( num * dit) / dit
	elseif _type == 2 then
		return math.floor( num * dit + 0.5) / dit
	else
		return math.ceil( num * dit) / dit
	end
end
-- 只保留一位描述
function NumberToString1(num, fig)
	num = tonumber(num)
	fig = fig or 1
	local str = ""
	if fig == 1 then
		if num < 10000 then
			str = num
		elseif num < 10000000 then
            num = NumberCutting(num / 10000, 2)
			str = num.." 万"
		elseif num < 100000000 then
            num = NumberCutting(num / 10000000, 2)
			str = num.." 千万"
		else
            num = NumberCutting(num / 100000000)
			str = num.." 亿"
		end
	elseif fig == 2 then
		if num < 1000 then
			str = num
		elseif num < 1000000 then
            num = NumberCutting(num / 1000, 2)
			str = num.." K"
		elseif num < 1000000000 then
            num = NumberCutting(num / 1000000, 2)
			str = num.." M"
		else
            num = NumberCutting(num / 1000000000, 2)
			str = num.." G"
		end 
	elseif fig == 3 then
		if num < 1000000 then
			str = num
		else
            num =math.floor(num / 10000)
			str = num.." 万"
		end
	end
	return str
end
---超过10亿显示为亿并保留2位，其它全显
function NumberToString2(num)
	num = tonumber(num)
	local str = ""
	if num < 10000000 then			--- 千万
		str = num
	else
		num = math.min(num, 9999999999)
		str = math.floor(num / 10000).." 万"
	end
	return str
end
---超过万用万，超过亿用亿，保留1位小数
function NumberToString3(num)
	num = tonumber(num)
	local str = ""
	if num < 10000 then
	str = num
	elseif num < 100000000 then		--- 亿
		str = (math.floor(num / 1000) / 10).."万"
	else
		str = (math.floor(num / 10000000) / 10).. "亿"
	end
	return str
end

function NumberToString4(num)
	num = tonumber(num)
	local str = ""
	if num < 10000 then
		str = num
	elseif num < 100000000 then		--- 亿
	str = math.floor(num / 10000).."万"
	else
		str = (math.floor(num / 1000000) / 100).. "亿"
	end
	return str
end

--超过亿用亿做单位保留两位有效数字
function NumberToString5(num)
	num = tonumber(num)
	local str = ""
	if num < 100000000 then
		str = num
	else
		str = (math.floor(num / 1000000) / 100).. "亿"
	end
	return str
end

--纯数字逗号显示(每三位显示)
function NumberToString6(numTmp)
	 local resultNum = numTmp
	 if type(numTmp) == "number" then
		 local inter, point = math.modf(numTmp)
		 local strNum = tostring(inter)
		 local newStr = ""
		 local numLen = string.len(strNum)
		 local count = 0
		 for i = numLen, 1, -1 do
			 if count % 3 == 0 and count ~= 0 then
			 newStr = string.format("%s,%s",string.sub(strNum,i,i),newStr)
			 else
			 newStr = string.format("%s%s",string.sub(strNum,i,i),newStr)
			 end
		     count = count + 1
		 end
		 if point > 0 then
			 --存在小数点，
			 local strPoint = string.format("%.2f", point )
			 resultNum = string.format("%s%s",newStr,string.sub(strPoint,2, string.len(strPoint )))
		 else
		     resultNum = newStr
		 end
	 end
	 return resultNum
 end

 
-- 获取最后一位字符
function GetLastIndexOf(str, char)
	local ts = string.reverse(str)
	local _, i = string.find(ts, char)
	return string.len(ts) - i + 1
end

---math 扩展---------------------------------------------------------------------------------------
local Math = math or {}
function Math.clam(num, min, max) return math.max(min, math.min(max, num)) end
---string 扩展---------------------------------------------------------------------------------------

local String = string or {}
function String.StartWith(str, param)
	if not param or not str or type(param) ~= "string" or type(str) ~= "string" then return false end
	return param == string.sub(str, 1, string.len(param))
end

function String.EndWith(str, param)
	if not param or not str or type(param) ~= "string" or type(str) ~= "string" then return false end
	local ls = string.len(str)
	local lp = string.len(param)
	if lp > ls then return false end
	return param == string.sub(str, ls - lp)
end

function String.LastChar(str)
	if not str or type(str) ~= "string" or str == "" then return "" end
	return string.sub(str,string.len(str))
end

function String.Has(str, chr)
	if not str or type(str) ~= "string" then return false end
	return string.find(str, chr) ~= nil
end

function String.Link(tab, len, chr)
	local str = nil
	if len > 0 then
		for i = 1, len do
			if tab[i] then
				if str then
					str = str..chr..tostring(tab[i])
				else
					str = tostring(tab[i])
				end
			end
		end
	end
	return str
end
--字符串分割 如  xxx_1  
function String.Split(str , split_char)
 local sub_str_tab = {};
    while (true) do
        local pos = string.find(str, split_char);
        if (not pos) then
            sub_str_tab[#sub_str_tab + 1] = str;
            break;
        end
        local sub_str = string.sub(str, 1, pos - 1);
        sub_str_tab[#sub_str_tab + 1] = sub_str;
        str = string.sub(str, pos + 1, #str);
    end
 
    return sub_str_tab;
end

List={}
function List.IndexOf(table,va)
	for k,v in ipairs(table) do
		if v==va then
			return k;
		end
	end
    return -1;
end
function List.Contains(table,va)
    for k,v in ipairs(table) do
        if v==va then
            return true;
        end
    end
    return false;
end


------------------------------------------------------------------------------------------
--- fig  ,  type
--- 1    ,  "00:00:00"
--- 2    ,  "0小时0分0秒"
--- 3    ,  "0小时0分0秒"/"0分0秒"/"0秒"
function NumberToHour(num, fig)
	local str = ""
	local sec = num % 60
	num = math.floor(num / 60)
	local min = num % 60
	num = math.floor(num / 60)
	local hour = num % 24
	if fig == 1 then
		str = string.format("%02d:%02d:%02d", hour, min, sec)
	elseif fig == 2 then
		str = string.format("%d小时%d分%d秒", hour, min, sec)
	elseif fig == 3 then
		if hour > 0 then
			str = string.format("%d小时%d分%d秒", hour, min, sec)
		elseif min > 0 then
			str = string.format("%d分%d秒", min, sec)
		else
			str = string.format("%d秒", sec)
		end
	end
	return str
end

function NumberToHour1(num)
	local sec = num % 60
	num = math.floor(num / 60)
	local min = num % 60
	return string.format("%02d:%02d", min, sec)
end

--- fig		, type
--- 1 		, "0y0m0d"
--- 2		, "0y0m0d"/"0d"/"0d"
--- 3		, "0Y0M0D"
---	4		, "0Y0M0D"/"0M0D"/"0D"
--- 5		, "0 Year 0 Month 0 Day"
--- 6		, "0 Year 0 Month 0 Day"/"Month 0 Day"/"0 Day"
--- 7		, "0年0月0日"
--- 8		, "0年0月0日"/"0月0日"/"0日"
--- 9		, "0年0月0天"
--- 10		, "0年0月0天"/"0月0天"/"0天"
function LeftNumberToLeftDay(num, fig)
	return TargetDayToLeftDay(os.time() + num, fig)
end


--- fig		, type
--- 1 		, "0y0m0d"
--- 2		, "0y0m0d"/"0d"/"0d"
--- 3		, "0Y0M0D"
---	4		, "0Y0M0D"/"0M0D"/"0D"
--- 5		, "0 Year 0 Month 0 Day"
--- 6		, "0 Year 0 Month 0 Day"/"Month 0 Day"/"0 Day"
--- 7		, "0年0月0天"
--- 8		, "0年0月0天"/"0月0天"/"0天"
--- 9		, "0年0月0天"
--- 10		, "0年0月0天"/"0月0天"/"0天"
function TargetDayToLeftDay(num, fig)
	local str = ""
	local now = os.date("*t", os.time())
	local target = os.date("*t", num)
	local year = target.year - now.year
	local month = target.month - now.month
	local day = target.day - now.day
	if day < 0 then
		month = month - 1
		local top = 0
		if now.month == 4 or now.month == 6 or 	now.month == 9 or now.month == 11 then
			top = 30
		elseif now.month == 2 then
			top = ((now.year % 4 == 0 and now.year % 100 ~= 0 ) or new % 400 == 0 ) and 29 or 28
		else
			top = 31
		end
		day = top - now.day + target.day
	end
	if month < 0 then
		year = year - 1
		month = month + 12
	end
	if year < 0 then
		str = "-1"
	else
		local y = ""
		local m = ""
		local d = ""
		if fig <= 2 then
			y = "y"
			m = "m"
			d = "d"
		elseif fig <= 4 then
			y = "Y"
			m = "M"
			d = "D"
		elseif fig <= 6 then
			y = " Year"
			m = " Month"
			d = " Day"
		elseif fig <= 8 then
			y = "年"
			m = "月"
			d = "日"
		elseif fig <= 10 then
			y = "年"
			m = "月"
			d = "天"
		end
		if fig % 2 == 0 or year > 0 then
			str = string.format("%d"..y.."%d"..m.."%d"..d, year, month, day)
		elseif month > 0 then
			str = string.format("%d"..m.."%d"..d, month, day)
		else
			str = string.format("%d"..d, day)
		end
	end
	return str
end

--- 保留兩位， 最低一位
function NumberToTime1(num)
	num = math.floor(tonumber(num))
	local sec = num % 60
	num = math.floor(num / 60)
	local min =  num % 60
	num = math.floor(num / 60)
	local hour = num % 24
	local day =  math.floor(num / 24)

	if day > 0 then
		return day.." 天"..hour.." 时"
	elseif hour > 0 then
		return hour.." 时"..min.." 分"
	elseif min > 0 then
		return min.." 分"..sec.." 秒"
	else
		return sec.." 秒"
	end
end

--- 两位数 不够就补0
--- fig		, type
--- 1 		, 00天00小时00分
--- 2		, 00小时00分00秒
function NumberToDayHour(t,fig)
	t = math.floor(t)
	local d, h , m , s = 0,0,0,0
	if (t < 0) then
		return
	elseif (t < 60) then
		s = t
	elseif ( t < 3600) then
		s = t % 60
		m = math.floor(t / 60)
	elseif (t < 3600 * 24 ) then
		s = t % 60
		m = math.floor(t / 60) % 60
		h = math.floor(t / (60 * 60))
	else
		s = t % 60
		m = math.floor(t / 60) % 60
		h = math.floor(t / (60 * 60)) % 24
		d = math.floor(t / (60 * 60 * 24))
	end
	if s < 10 then s="0"..s end
	if m < 10 then m="0"..m end
	if h < 10 then h="0"..h end
	if d < 10 then d="0"..d end
	if not fig or fig == 1 then
		return d..'天'..h..'时'..m..'分'
	end
	if fig == 2 then
		return h..'时'..m..'分'..s..'秒'
	end
end
--牌id
--1 2 3 ... 52
--牌值
--1 - 13  A 2 3 4 5 6 7 8 9 10 J Q K
--花色
--1 2 3 4  黑红梅方
function GetPokerInfo(id)
	id = tonumber(id)
	if id == 53 then
		return "joker", 1
	elseif id == 54 then
		return "JOKER", 2
	end

	id = math.min(math.max(id , 1), 52)
	local num = math.floor( (id + 3) / 4)
	local color = ((id - 1) % 4) + 1
	if num == 1 then
		num = 'a'
	elseif num == 11 then
		num = 'j'
	elseif num == 12 then
		num = 'q'
	elseif num == 13 then
		num = 'k'
	end
	return tostring(num), color
end

--- 十进制, 数值位数
function GetNumberFigure(num)
	num = math.abs(tonumber(num or 0))
	local cnt = 0
	while num >= 1 do
		num = num / 10
		cnt = cnt + 1
	end
	return cnt
end

function GetInhomogeneityGrids(length, height, row, col, noise)
	row = math.max(1, row)
	col = math.max(1, col)
	noise = math.abs(noise)
	local list = {}
	local len = length / row
	local hei = height / col
	for i = 1, row do
		for m = 1, col do
			table.insert(list, {(i - 1) * len + len * 0.5, (m - 1) * hei + hei * 0.5})
		end
	end

	local half_length = length * 0.5
	local half_height = height * 0.5
	for i, v in ipairs(list) do
		list[i][1] = list[i][1] + math.random(-noise, noise) - half_length
		list[i][2] = list[i][2] + math.random(-noise, noise) - half_height
	end
	return list
end

--返回两个值之间的随机数
local seed = os.time()
function Random(min, max)
	seed = seed + 1
	math.randomseed(tostring(seed))
	return math.random(min, max)
end

---插入拆分符
---str~=""
---offset>0
function InsertSplit(str,offset,split)
	if str == "" or offset<=0 then
		return "error param"
	end
	local len = string.len(str)
	local s = ""
	for i = len, 1 ,-offset do
		local index = i-offset+1
		if index<0 then
			index = 1
		end
		local v = string.sub(str,index,i)
		if s ~= "" and v ~= "" then
			s = v ..split.. s
		else
			s = v .. s
		end
	end
	return s
end

---设置物品图标数量天数等
function SetItemUI(trans, itemId, itemCount, itemName, useNameJointCount)
	local commonData = GetModel(FishBattle.ModelType.CommonModel):GetData()
	local icon = trans:Find("Coin")
	if not icon then
		icon = trans:Find("Icon")
	end
	local itemConfig = commonData:GetItemConfigById(itemId)
	if not itemConfig then
		return
	end
	local img = icon:GetComponent("Image")
	img.sprite = FishBattle.ResManager.LoadSCSprite(itemConfig.icon_s)
	img:SetNativeSize()
	local countTrans = trans:Find("TextCount")
	local countLabel = nil
	if countTrans then
		countLabel = countTrans:GetComponent("Text")
		if itemCount then
			countLabel.text = NumberToString3(itemCount)
		elseif itemName then
			countLabel.text = itemName
		end
	end
	local nameLabel = trans:Find("TextName")
	if nameLabel then
		if itemName then
			nameLabel:GetComponent("Text").text = itemName
		else
			nameLabel:GetComponent("Text").text = itemConfig.name_s
		end
	end
	--特殊类型图标放大
	if itemConfig.type_i == 7 then
		--翅膀
		icon.localScale = Vector3.one * 0.3
	elseif itemConfig.type_i == 6 then
		--炮
		icon.localScale = Vector3.one * 0.22
	elseif itemConfig.type_i == 11 then
		--天赋头像
		icon.localScale = Vector3.one * 0.61
	else
		icon.localScale = Vector3.one * 0.55
	end
	if itemConfig.icon_s == "sc_dj_item_5122" or itemConfig.icon_s == "sc_dj_item_5123" then
		icon.localScale = Vector3.one * 0.35
	end
	--是否需要显示天数
	local day = trans:Find("Img_LeftTop")
	if day then
		if itemConfig.experience_time_i > 0 then
			day.gameObject:SetActive(true)
			local daysStr = math.ceil(itemConfig.experience_time_i/3600/24)..FishBattle.Words[100009]
			day:Find("Text_Day"):GetComponent("Text").text = daysStr
		else
			day.gameObject:SetActive(false)
		end
	end
	--把名字和数量拼一起，有天数显示天数
	if useNameJointCount then
		if countLabel then
			if itemConfig.type_i == 6 or itemConfig.type_i == 7 then
			    countLabel.text = itemConfig.name_s
			else
				countLabel.text = itemConfig.name_s.." x"..NumberToString3(itemCount)
			end
			if itemConfig.experience_time_i > 0 then
				local daysStr = math.ceil(itemConfig.experience_time_i/3600/24)..FishBattle.Words[100009]
				countLabel.text = countLabel.text .. "(".. daysStr..")"
			end
		end
	end
end

function SetColor(trans, color, ignoreNameList)
	local img = trans:GetComponent("Image")
	if not img then
		img = trans:GetComponent("RawImage")
	end
	if img then
		if ignoreNameList then
			local ignore = false
			for key, value in pairs(ignoreNameList) do
				if img.name == value then
					ignore = true
					break
				end
			end
			if not ignore then
				img.color = color
			end
		else
			img.color = color
		end
	end
	local text = trans:GetComponent("Text")
	if text then
		if ignoreNameList then
			local ignore = false
			for key, value in pairs(ignoreNameList) do
				if text.name == value then
					ignore = true
					break
				end
			end
			if not ignore then
				text.color = color
			end
		else
			text.color = color
		end
	end
	for i = 1, trans.childCount do
		SetColor(trans:GetChild(i-1), color, ignoreNameList)
	end
end

--读取json数据里字段个数
function JsonLength(json)
	local length = 0;
	for key, value in pairs(json) do
		length = length + 1
	end
	return length;
end

--判断表里是否存在某个Key
function ContainsKey(data, key)
	if data then
		for k, v in pairs(data) do
			print(k,v)
			if k == key then
				return true
			end
		end
	end
	return false;
end

--判断字符串是否为nil或空串
function isEmpty(str)
	return str == nil or str == "";
end

--段落文本支持输入空格不自动换行
function TextSurportSpace(text)
	return string.gsub(text, " ", "\u{00A0}\u{00A0}")
end

--同C#里的Mathf.Clamp()
function Clamp(value, min, max)
	if value and min and max then
		if value < min then
			return min
		elseif value > max then
			return max
		end
	end
	return value
end

--TableView中跳到指定的Cell的位置
local function TableViewJumpToCell(tableView, cellIndex, isVertical, duration)
    if not duration then
        duration = 0.5
    end
	if not cellIndex or cellIndex < 1 then
		cellIndex = 1
	end
    local pos = tableView:GetScrollYForCol(cellIndex - 1, true)
    local toNorPos = 0
	if isVertical then
		toNorPos = Clamp(pos / tableView.scrollableHeight, 0, 1)
	else
		toNorPos = Clamp(pos / tableView.scrollableWidth, 0, 1)
	end
	local scrollRect = tableView:GetComponentInChildren(typeof(UnityEngine.UI.ScrollRect))
    if duration > 0 then
        DG.Tweening.DOTween.To(
            DG.Tweening.Core.DOGetter_float(
                function()
					if isVertical then
						return scrollRect.verticalNormalizedPosition
					else
						return scrollRect.horizontalNormalizedPosition
					end
                end
            ),
            DG.Tweening.Core.DOSetter_float(
                function(value)
					if isVertical then
						scrollRect.verticalNormalizedPosition = value
					else
						scrollRect.horizontalNormalizedPosition = value
					end
                end
            ),
            toNorPos,
            duration
        ):SetEase(Ease.InOutSine)
    else
		if isVertical then
			scrollRect.verticalNormalizedPosition = toNorPos
		else
			scrollRect.horizontalNormalizedPosition = toNorPos
		end
    end
end

--TableView(纵向)中跳到指定的Cell的位置
function TableViewJumpToCellY(tableView, cellIndex, duration)
	TableViewJumpToCell(tableView, cellIndex, true, duration)
end

--TableView(横向)中跳到指定的Cell的位置
function TableViewJumpToCellX(tableView, cellIndex, duration)
	TableViewJumpToCell(tableView, cellIndex, false, duration)
end

--TableView左右移动一定距离
local function TableViewMove(tableView, distance, isVertical, duration)
    if not duration then
        duration = 0.5
    end
	local scrollRect = tableView:GetComponentInChildren(typeof(UnityEngine.UI.ScrollRect))
    local totalLength = 0
	local currNorPos = 0
	if isVertical then
		totalLength = tableView.scrollableHeight
		currNorPos = scrollRect.verticalNormalizedPosition
	else
		totalLength = tableView.scrollableWidth
		currNorPos = scrollRect.horizontalNormalizedPosition
	end
	local toNorPos = Clamp(currNorPos +  distance/totalLength, 0, 1)
    if duration > 0 then
        DG.Tweening.DOTween.To(
            DG.Tweening.Core.DOGetter_float(
                function()
					if isVertical then
						return scrollRect.verticalNormalizedPosition
					else
						return scrollRect.horizontalNormalizedPosition
					end
                end
            ),
            DG.Tweening.Core.DOSetter_float(
                function(value)
					if isVertical then
						scrollRect.verticalNormalizedPosition = value
					else
						scrollRect.horizontalNormalizedPosition = value
					end
                end
            ),
            toNorPos,
            duration
        ):SetEase(Ease.InOutSine)
    else
		if isVertical then
			scrollRect.verticalNormalizedPosition = toNorPos
		else
			scrollRect.horizontalNormalizedPosition = toNorPos
		end
    end
end

--TableView(纵向)左右移动一定距离
function TableViewMoveY(tableView, distance, duration)
	TableViewMove(tableView, distance, true, duration)
end

--TableView(横向)左右移动一定距离
function TableViewMoveX(tableView, distance, duration)
	TableViewMove(tableView, distance, false, duration)
end

--当前是否海王渔场
function isHaiWangFishery(id)
	local list = {
	FishBattle.FisheryType.HaiWangLG,
	FishBattle.FisheryType.HaiWangJS,
	FishBattle.FisheryType.HaiWangML
    }
	for k, v in pairs(list) do
		if id == v then
			return true
		end
	end
	return false
end

--判断字符串是否需要把元替换成点券
function CheckUsePointTicket(text)
	local commonData = GetModel(FishBattle.ModelType.CommonModel):GetData()
	if commonData:GetFunKey(FishBattle.FunKeyType.UsePointTicket) then
		return string.gsub(text, "元", FishBattle.Words[100236])
	end
	return text
end

--16进制颜色码(#000000)转Color(R,G,B)
function Hex2Color(hex, alpha)
	hex = string.gsub(hex, '#', '')
    local s
	s=string.sub(hex,1,2)
	local r=tonumber(s,16)/255
	s=string.sub(hex,3,4)
	local g=tonumber(s,16)/255
	s=string.sub(hex,5,6)
	local b=tonumber(s,16)/255
	--保留小数点后3位
	local afterDot = '%0.3f'
	if string.len(hex) == 8 then
		s=string.sub(hex,7,8)
		local a=tonumber(s,16)/255
	    Color(string.format(afterDot,r),string.format(afterDot,g),string.format(afterDot,b),string.format(afterDot,a))
	end
	return Color(string.format(afterDot,r),string.format(afterDot,g),string.format(afterDot,b))
end

--是否是iPhone的刘海屏
function IsIPhoneLiuHaiPing(callback)
	if callback then
		if UnityEngine.Application.platform == UnityEngine.RuntimePlatform.IPhonePlayer then
			FishBattle.SDKManager.getMarginSize(function (dataJson)
				local info = json.decode(dataJson.Result)
				callback(info.screenBottomMargin > 0)
			end)
		else
			callback(false)
		end
	end
end

-- 判断表里是否存在某个Key
function TableContainsKey(table, key)
	for k, _ in pairs(table) do
		if k == key then
			return true
		end
	end
	return false
end

-- 判断表里是否存在某个值
function TableContainsValue(table, value)
	for _, v in pairs(table) do
		if v == value then
			return true
		end
	end
	return false
end